<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
        margin: 0;
        padding: 0;
    }

    h2 {
        text-align: center;
    }

    .box {
        width: 600px;
        margin: 50px auto;
        display: flex;
        font-size: 25px;
        line-height: 40px;
    }

    .qs {

        width: 450px;
        height: 40px;
        color: red;

    }

    .btns {
        text-align: center;
    }

    .btns button {
        width: 120px;
        height: 35px;
        margin: 0 50px;
    }
</style>
</head>
<body>
  <h2>随机点名</h2>
  <div class="box" >
    <span> 名字是：</span>
    <div class="qs"> 这里显示名字</div>
  </div>
  <div class="btns"> 
    <button class="start">开始点名</button>
    <button class="stop">停止点名</button>
  </div>

  <script>
    let st;
    let random;
    const arr = ['张三', '李四', '王五', '赵六', '钱七'];
    const start = document.querySelector('.start');
    // 开始按钮
    start.addEventListener('click', () => {
      st= setInterval(() => {   
      random=parseInt(Math.random()*arr.length);
      const qs=document.querySelector('.qs');
      qs.innerHTML=arr[random];}, 10)
      if(arr.length===1)
    {
      start.disabled=stop.disabled =true;
    }
    })
    
    // 关闭按钮
    const stop = document.querySelector('.stop');
    stop.addEventListener('click', () => {
      clearInterval(st);
      
      arr.splice(random,1);
      localStorage.setItem('arr', JSON.stringify(arr));
    })
  </script>
</body>
</html>